﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NetJsWire.Direct.attributes;
using NetJsWire.Lite.Widgets.UI;

namespace UIProject
{
    [DirectAction]
    public partial class LiteWindow : Window
    {
        public LiteWindow()
        {
            InitializeComponent();

            // Show some inline Data
            jsonStore1.Data = new { Result = new List<object> { new { Id = 0, Name = "First" }, new { Id = 1, Name = "Second" } } };

            // Add a BoxComponent as a public member of our Window, beauty of dynamics...
            ( ( dynamic ) this ).AnotherValue = new BoxComponent { Name = "ttt", Width = 100, Height = 100 };

            // Add a reference to the Test function we declaring below so we can invoque it directly from our Window object
            // This is just for illustration purposes, consider using a static class to declare Direct functions.
            ( ( dynamic ) this ).TestFunction = "LiteWindow.Test";
        }

        // This function will be called by panelButton, check the handler code.
        [DirectMethod( OutputHandling = OutputHandling.JSON )]
        public static string Test()
        {
            return "alert( 'ttt width:' + Ext.getCmp('liteWindow').AnotherValue.width )";
        }
    }
}
